package org.xmonkey.notifier;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobChangeListener;
import org.xmonkey.Messages;
import org.xmonkey.util.Log;

/**
 * This class represents a listener that check on a job's progresses.
 * It is responsible for notifying start and end events.
 * @author jacopom
 *
 */
public final class JobChangeListener implements IJobChangeListener {
	private IProject project;
	
	public JobChangeListener(IProject project) {
		this.project = project;
	}

	public void done(IJobChangeEvent event) {
		SubscriptionsRegister.getInstance().notifyEnd(project);
		Log.printInfo(Messages.JobChangeListener_0 + this.project.getName(), null);
	}
	
	public void running(IJobChangeEvent event) {
		SubscriptionsRegister.getInstance().notifyStart(project);
		Log.printInfo(Messages.JobChangeListener_1 + this.project.getName(), null);
	}
	
	public void aboutToRun(IJobChangeEvent event) {}
	public void awake(IJobChangeEvent event) {}
	public void scheduled(IJobChangeEvent event) {}
	public void sleeping(IJobChangeEvent event) {}
}
